<template>
	<!-- 积分详情 -->
	<page-container :shownav="true" :isback="true" navtitle="积分详情" :istabbox="false">
		<view class="content-root">
			<!-- 积分详情列表 begin -->
			<view class="content-item integral-ranking">
				<view class="integral-ranking-info">
					<!-- tab begin -->
					<!-- <view class="tabbar">
						<view class="item" v-for="(item, index) in tabList" :key="index"
							:class="{ active: tabIndex === index }" @tap="switchTab(index)">
							{{ item }}
							<view class="underline" :style="{ border: tabIndex === index ? '2px solid #ad2325' : '0' }">
							</view>
						</view>
					</view> -->
					<!-- tab end -->
					<swiper :current="tabIndex" :duration="300" :show-scrollbar="false"
						:style="{ height: swiperHeight + 'px' }">
						<swiper-item class="integral-list" v-for="(item, index) in tabList" :key="index">
							<view class="row">
								<view class="grid">
									<view class="item">
										<view class="user-info">
											<view class="name">详情详情详情详情详情详情详情</view>
											<view class="role">2023.12.30</view>
										</view>
									</view>
									<view class="total-integral">
										<view class="val">+20</view>
									</view>
								</view>
								<view class="grid">
									<view class="item">
										<view class="user-info">
											<view class="name">详情详情详情详情详情详情详情</view>
											<view class="role">2023.12.30</view>
										</view>
									</view>
									<view class="total-integral">
										<view class="val">+20</view>
									</view>
								</view>
								<view class="grid">
									<view class="item">
										<view class="user-info">
											<view class="name">详情详情详情详情详情详情详情</view>
											<view class="role">2023.12.30</view>
										</view>
									</view>
									<view class="total-integral">
										<view class="val">+20</view>
									</view>
								</view>
								<view class="grid">
									<view class="item">
										<view class="user-info">
											<view class="name">详情详情详情详情详情详情详情</view>
											<view class="role">2023.12.30</view>
										</view>
									</view>
									<view class="total-integral">
										<view class="val">+20</view>
									</view>
								</view>
							</view>
						</swiper-item>
					</swiper>
				</view>
			</view>
			<!-- 积分排名列表 end -->
		</view>
	</page-container>
</template>

<script>
	export default {
		data() {
			return {
				swiperHeight: 0,
				tabIndex: 0,
				tabList: [
					"全部",
					"建议",
				]
			}
		},
		onLoad() {
			// this.boardcast = await this.$api('boardcast')
			this.$nextTick(() => {
				const query = uni.createSelectorQuery().in(this);
				query.select('.row').boundingClientRect((rect) => {
					if (rect && rect.height > 0) {
						this.swiperHeight = rect.height + 30 + 15;
					} else {
						console.error('Failed to get the container\'s bounding client rectangle');
					}
				}).exec();
			});
		},
		methods: {
			switchTab(index) {
				if (this.tabIndex === index) return;
				this.tabIndex = index;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content-root {
		overflow: auto;
		height: 100%;
		padding: 20rpx
	}

	.content {
		padding: 20rpx;
	}

	.content-item {
		width: 100%;

		// padding: 20rpx 40rpx;
		.header {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 20rpx;

			.title {
				font-size: $font-size-lg;
				font-weight: 500;
			}

			.subtitle {
				font-size: $font-size-base;
				color: $text-color-grey;
			}
		}
	}

	.integral-ranking {

		.integral-ranking-info {
			// width: 100%;
			background-color: $bg-color-white;
			padding: 20rpx 40rpx;
			border-radius: $border-radius-lg;

			.tabbar {
				display: flex;
				overflow-x: auto;
				white-space: nowrap;
				justify-content: space-around;
				-webkit-overflow-scrolling: touch;
				padding: 20rpx 0;

				.item {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					font-size: $font-size-lg;
					padding: 0 10rpx;
				}

				.underline {
					// background: none;
					// border: 2px solid #ad2325;
					border-radius: 0 0 50% 50% / 0 0 100% 100%;
					border-top: none !important;
					width: 60%;
					height: 16rpx;
					margin-top: 10rpx;
					// background: #ad2325;
					// border-radius: 15px
				}

				.active {
					color: #ad2325;
				}
			}
		}

		.row {
			display: flex;
			flex-wrap: wrap;
			padding: 10rpx;
			height: auto;

			.grid {
				display: flex;
				flex-direction: unset;
				align-items: start;
				justify-content: space-between;
				align-items: center;
				background: #fff;
				width: 100%;
				padding: 20rpx 0;
				border-radius: $border-radius-lg;
				border-bottom: 1rpx solid #c7c7c7;

				.item {
					display: flex;
					justify-content: space-between;
					align-items: center;

					.name {
						font-size: $font-size-lg;
					}

					.role {
						color: #ababab;
					}

					view {
						margin-right: 20px;
					}

					.avatar {
						margin-right: 20px;
					}
				}

				.total-integral {
					display: flex;
					align-items: center;

					.val {
						margin-left: 15rpx;
						font-size: $font-size-lg;
						color: #ad2325;
					}
				}

				image {
					width: 70rpx;
					height: 70rpx;
					border-radius: $border-radius-lg;
				}

				.title {
					margin-left: 20rpx;
				}
			}
		}
	}

	/deep/ .uni-scroll-view {
		height: auto;
	}

	/deep/ .uni-scroll-view-content {
		height: auto;
	}
</style>